//
//  ST_EditMyInfoSectionView.swift
//  btvideo
//
//  Created by mac on 2020/1/8.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwifterSwift

class ST_EditMyInfoSectionView: UITableViewHeaderFooterView {

    static let sectionLabelBottomEdge = 11.cgFloat
    
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        
        
        self.contentView.backgroundColor = .white
        
        self.contentView.addSubview(content_label)
        content_label.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview().offset(-ST_EditMyInfoSectionView.sectionLabelBottomEdge)
            make.left.equalToSuperview().offset(15)
        }
        
        
        self.contentView.addSubview(right_nav_image_view)
        right_nav_image_view.snp.makeConstraints { (make) in
            make.centerY.equalTo(content_label)
            make.left.equalTo(content_label.snp.right).offset(5)
            make.width.height.equalTo(14)
        }
        
        
        contentView.addSubview(other_supplementarity_label)
        other_supplementarity_label.snp.makeConstraints { make in
            make.centerY.equalTo(right_nav_image_view)
            make.left.equalTo(right_nav_image_view.snp.right).offset(5)
        }
        
        
        contentView.addSubview(eventBtn)
        eventBtn.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    var click_closure:((String)->())?
    @objc fileprivate func click_handle(){
        click_closure?(arguments.first ?? "")
    }
    
    fileprivate lazy var eventBtn:UIButton = {
        let btn = UIButton.init(type: UIButton.ButtonType.custom)
        btn.addTarget(self, action: #selector(click_handle), for: UIControl.Event.touchUpInside)
        return btn
    }()
    
    fileprivate lazy var content_label:UILabel = {
        let control = UILabel.init()
//        control.backgroundColor = Color.random
        control.text = ""
        control.textColor = Color.init(hexString: "#333333")
        
//        control.textAlignment = .center
        control.font = UIFont.systemFont(ofSize: 16, weight: UIFont.Weight.semibold)
        return control
    }()
    
    fileprivate lazy var other_supplementarity_label:UILabel = {
        let control = UILabel.init()
        control.textColor = Color.init(hexString: "#ED3E58")
        control.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)
        return control
    }()
    
    fileprivate lazy var right_nav_image_view:UIImageView = {
        let control = UIImageView.init(image: ST_ImageUtils.imageName("个人中心_icon_下一页")!)
        return control
    }()
    
    
//    MARK: - Bind Data
    var arguments = [String]() {
        didSet{
        
        content_label.text = arguments.first
        
        other_supplementarity_label.text = arguments[safe:1]
        
        right_nav_image_view.isHidden = arguments.first == "个人资料"
            
        }
    }
    
}
